package com.boot.security.server.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.boot.security.server.model.Book;

@Mapper
public interface BookDao {

    @Select("select * from book t where t.id = #{id}")
    Book getById(Long id);

    @Delete("delete from book where id = #{id}")
    int delete(Long id);

    int update(Book book);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into book(ID, BOOK_NAME, AUTHOR, BODY, CREATE_DATE, UPDATE_DATE) values(#{ID}, #{BOOKNAME}, #{AUTHOR}, #{BODY}, #{CREATEDATE}, #{UPDATEDATE})")
    int save(Book book);
    
    int count(@Param("params") Map<String, Object> params);

    List<Book> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);
}
